class Food{
    element:HTMLElement;
    constructor() {
        //加个叹号，就可以忽略情况
        this.element = document.getElementById('food')!;
    }
    get X(){
        return this.element.offsetLeft;
    }

    get Y(){
        return this.element.offsetTop;
    }

    change(){
        let top = Math.round(Math.random() * 29) * 10;
        let left = Math.round(Math.random() * 29) * 10;
        this.element.style.left = left + 'px';
        this.element.style.top = top + 'px';
    }

}

export default Food;